home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 286_01 / frame.c < prev    next >
Text File  |  1989-05-23  |  1KB  |  54 lines

  1. #include <stdio.h>
  2. #include <gds.h>
  3. #include <prtfont.h>
  4.  
  5. #define ERROR (-1)
  6. #define OK 0
  7.  
  8. CreateFrame(horizontal,vertical)
  9. int horizontal,vertical;
  10. {
  11.     char huge *halloc();
  12.     int ff,width;
  13.     register struct fdesc *fptr;
  14.  
  15.     if ((ff=freeframe()) == 0) {
  16.         graderror(6,7);
  17.     }
  18.     fptr = & FTABLE[ff];
  19.     width=(horizontal + 15) >> 4;
  20.     if ((fptr->faddr=nor_ptr((int far *) halloc(((long) width)*vertical,2))) ==
  21.                              (int far *) NULL) {
  22.         graderror(6,8,horizontal,vertical);
  23.     }
  24.     fptr->forgx=fptr->forgy=fptr->fwinx1=fptr->fwiny1=0;
  25.     fptr->status=USED;
  26.     fptr->ln_byte=width << 1;
  27.     fptr->fwinx2=fptr->horz=(width << 4) - 1;
  28.     fptr->fwiny2=fptr->vert=vertical - 1;
  29.     return(ff);
  30. }
  31.  
  32. freeframe()
  33. {
  34.     register int loop;
  35.  
  36.     for(loop=1; loop < NFRAME ; loop++)
  37.         if (FTABLE[loop].status == NOT_USED)
  38.             return(loop);
  39.     return(0);
  40. }
  41.  
  42. int RemvFrame(ff)
  43. int ff;
  44. {
  45.     register struct fdesc *fptr;
  46.  
  47.     if ((fptr=&FTABLE[ff])->status == NOT_USED) return(ERROR);
  48.     if (fptr->status == PERMANENT) return(OK);
  49.     if (ff == CUR_FRAME) CUR_FRAME=0;
  50.     hfree(fptr->faddr);
  51.     return(OK);
  52. }
  53.  
  54.